using UnityEngine;

public class CameraController : MonoBehaviour
{
    public float moveSpeed = 5f;
    public float rotateSpeed = 100f;
    
    void Update()
    {
        // 平移
        float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
        float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
        
        transform.Translate(horizontal, 0, vertical);
        
        // 旋转 (鼠标右键)
        if (Input.GetMouseButton(1))
        {
            float mouseX = Input.GetAxis("Mouse X") * rotateSpeed * Time.deltaTime;
            float mouseY = Input.GetAxis("Mouse Y") * rotateSpeed * Time.deltaTime;
            
            transform.Rotate(Vector3.up, mouseX);
            transform.Rotate(Vector3.right, -mouseY);
        }
        
        // 缩放 (鼠标滚轮)
        float scroll = Input.GetAxis("Mouse ScrollWheel");
        transform.Translate(0, 0, scroll * moveSpeed * 10 * Time.deltaTime);
    }
}